//
//  HomeViewController.m
//  WarnDemo
//
//  Created by TuRing on 16/10/11.
//  Copyright © 2016年 You Ran. All rights reserved.
//

#import "HomeViewController.h"
#import "MapViewController.h"


@interface HomeViewController ()<UITableViewDataSource, UITableViewDelegate>

@end

@implementation HomeViewController

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
//    [self.navigationController setNavigationBarHidden:NO];
}

- (void)viewDidLoad {
    
    [super viewDidLoad];
    [self.navigationItem setTitle:@"应急预案"];
    self.tabBarController.tabBarItem.image = [UIImage
                                              imageNamed:@"home"];
    /** 改变navigation title的文本颜色*/
    NSDictionary *dic = @{NSForegroundColorAttributeName: [UIColor whiteColor]};
    self.navigationController.navigationBar.titleTextAttributes =dic;

    
    /** 更改返回按钮及文本颜色 **/
    self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
    
    /** 去掉返回按钮旁边的提示文本 **/
    [[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -60)
                                                         forBarMetrics:UIBarMetricsDefault];
    self.view.backgroundColor = [UIColor whiteColor];



    [self.navigationController.navigationBar setBarTintColor:[UIColor colorWithRed:10/255.0 green:158/255.0 blue:254/255.0 alpha:1.0]];
//    [self.navigationController.navigationBar setBarTintColor:[UIColor blueColor]];

}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 3;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *ID = @"cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }
    if (indexPath.row == 0) {
        cell.textLabel.text = @"深圳市天然气事件";
    } else if (indexPath.row == 1) {
        cell.textLabel.text = @"深圳市天然气管道事件";
    } else if (indexPath.row == 2) {
        cell.textLabel.text = @"深圳市石油事件";
    }
    
    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.row == 0) {
        MapViewController *mapVC = [[MapViewController alloc] init];
        mapVC.navigationItem.title = @"深圳市天然气事件";
        mapVC.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:mapVC animated:YES];
    } else if (indexPath.row == 1) {
        MapViewController *annotationVC = [[MapViewController alloc] init];
        annotationVC.title = @"深圳市天然气管道事件";
        [self.navigationController pushViewController:annotationVC animated:YES];
    } else if (indexPath.row == 2) {
        MapViewController *annotationVC = [[MapViewController alloc] init];
        annotationVC.title = @"深圳市石油事件";
        [self.navigationController pushViewController:annotationVC animated:YES];
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
